﻿
Partial Class MestreCodis
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not Me.IsPostBack Then
            Refrescar()
        End If
    End Sub
    Private Sub Refrescar()
        Dim servei As New EsportsLn.MestreCodi()
        'Databinding
        Me.grdMesteCodis.DataSource = servei.Llistat()
        Me.grdMesteCodis.DataBind()
        grdMesteCodis.DataKeyNames(0) = "codi"



    End Sub

    Protected Sub grdMesteCodis_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles grdMesteCodis.RowCommand
        If e.CommandName = "Editar" Then
            Dim codiSel As Integer
            codiSel = grdMesteCodis.SelectedValue
            Server.Transfer("MestreCodisDetall.aspx?codi=" & codiSel)
        End If
        If e.CommandName = "Eliminar" Then
            Dim servei As New EsportsLn.MestreCodi()
            Dim codiSel As Integer
            codiSel = grdMesteCodis.SelectedValue
            servei.Eliminar(codiSel)
            Refrescar()

        End If

    End Sub


    Protected Sub grdMesteCodis_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles grdMesteCodis.SelectedIndexChanged

    End Sub

    Protected Sub cmdInsert_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdInsert.Click
        Server.Transfer("MestreCodisDetall.aspx?mode=insert")

    End Sub
End Class
